// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const templatesProductRequst = {
    BASE_URL: confing.QC_URL + "/templateProduct",

    //多选删除按钮
    deletes(recordIds,callback){
        //拼接URL
        let url=this.BASE_URL+"/deletes?t=1";
        if(recordIds !=undefined){
            recordIds.forEach(recordId =>{
                url +="&recordId="+recordId;
            })
          request.delete(url,callback);
        }
    },
     //删除信息
     delete(recordId, callback) {
        request.delete(this.BASE_URL + "/" + recordId, callback);
    },

    //编辑信息
    edit(templateProduct, callback) {
        if (templateProduct != undefined && templateProduct.recordId != undefined) {
            request.put(this.BASE_URL + "/update", templateProduct, callback);
        }

    },
    //根据id查询
    gets(recordId,callback){
        if (recordId) {
            // 准备url
            let url = this.BASE_URL + "/gets?recordId=" + recordId;
            request.get(url, callback);
        }
    },
    //根据外键id查询信息
    get(templateId, callback) {
        request.get(this.BASE_URL + "/get?templateId=" + templateId, callback);
    },
    //保存信息
    save(templateProduct, callback) {
        if (templateProduct) {
            request.post(this.BASE_URL + "/save", templateProduct, callback);
        }
    }
     

    


}

// 将dictRequest暴漏出去
export default templatesProductRequst;